using Gateway.IApplication.Cache;
using Aurora.Redis;

namespace Gateway.Application;
/// <summary>
/// 
/// </summary>
public class CacheApp : ICacheApp
{
    private readonly IRedisCache _redisCache;
    /// <summary>
    /// 
    /// </summary>
    /// <param name="redisCache"></param>
    public CacheApp(IRedisCache redisCache)
    {
        _redisCache = redisCache;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pattern"></param>
    /// <returns></returns>
    public async Task<bool> Remove(string pattern)
    {
        if (pattern.EndsWith(":"))
        {
            return await _redisCache.DelByPatternAsync(pattern + "*") > 0;
        }

        return _redisCache.Del(pattern) > 0;
    }
}